package cn.lopr.mvc.frame.base;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @author shuangyang7
 * @date 2021/3/9 22:37
 */
public class RouteValue {

    private final Method method;

    private ParamMapping[] paramMappings;

    private boolean hasParam;
    private boolean isRequestBody;

    public RouteValue(Method method, ParamMapping[] paramMappings, boolean hasParam) {
        this.method = method;
        this.paramMappings = paramMappings;
        this.hasParam = hasParam;
    }

    public RouteValue(Method method, ParamMapping[] paramMappings, boolean hasParam, boolean isRequestBody) {
        this.method = method;
        this.paramMappings = paramMappings;
        this.hasParam = hasParam;
        this.isRequestBody = isRequestBody;
    }

    public RouteValue(Method method) {
        this.method = method;
    }

    public Method getMethod() {
        return method;
    }

    public boolean isHasParam() {
        return hasParam;
    }

    public ParamMapping[] getParamMappings() {
        return paramMappings;
    }

    public boolean isRequestBody() {
        return isRequestBody;
    }

    public void setRequestBody(boolean requestBody) {
        isRequestBody = requestBody;
    }

    @Override
    public String toString() {
        return "RouteValue{" +
                "method=" + method +
                ", paramMappings=" + Arrays.toString(paramMappings) +
                ", hasParam=" + hasParam +
                '}';
    }
}
